package teacher.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import teacher.bean.Treatise;
import teacher.bean.Teacher;
import teacher.page.Page;
import teacher.page.PageUtil;
import teacher.service.treatise;

import com.opensymphony.xwork2.ActionSupport;

public class listTre extends ActionSupport{
	
	private List<Treatise> treatises;
	private int currentPage;
	String suc;

	public String getSuc() {
		return suc;
	}

	public void setSuc(String suc) {
		this.suc = suc;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public List<Treatise> getTreatises() {
		return treatises;
	}

	public void setTreatises(List<Treatise> treatises) {
		this.treatises = treatises;
	}

	public String execute()
	{
		HttpServletRequest request=ServletActionContext.getRequest();
		Teacher tea=(Teacher)request.getSession().getAttribute("teacher");
		
		// 获得记录数
		int totalCount = new treatise().getCountTreatiseTea(tea);
		// 设置分页信息
		Page page = PageUtil.createPage(10, totalCount, currentPage);
		//取得该频道下的记录
		treatises=new treatise().selectTreatiseByTeacherPage(tea,page);
		
		request.setAttribute("treatises",treatises);
		request.setAttribute("page",page);
		return SUCCESS;
	}

}

